cmake_minimum_required(VERSION 3.17)

project(ffmpeg_prj)

set(ffmpeg_dir libs/ffmpeg)

set(ffmpeg_lib avcodec avformat avfilter postproc swresample swscale avdevice avutil)
set(ffmpeg_lib_dir  PUBLIC ${ffmpeg_dir}/libavcodec 
                    PUBLIC ${ffmpeg_dir}/libavdevice 
                    PUBLIC ${ffmpeg_dir}/libavfilter 
                    PUBLIC ${ffmpeg_dir}/libavformat 
                    PUBLIC ${ffmpeg_dir}/libavresample 
                    PUBLIC ${ffmpeg_dir}/libavutil 
                    PUBLIC ${ffmpeg_dir}/libpostproc 
                    PUBLIC ${ffmpeg_dir}/libswresample 
                    PUBLIC ${ffmpeg_dir}/libswscale
                    )

#/media/lhpc04/869762e7-5cfb-40a4-82aa-c0477c0fd3c2/workspace/code/摄像头/ffmpeg_decode/pic_ffmepg/src/bmp
set(bmp_dir PUBLIC src/rgb2bmp)

# add_executable(helloff ${prj_src})
# target_link_libraries(helloff ${ffmpeg_lib})


# ------------------- ffplay -------------------
set(prj_name ffplay)
# set(prj_name dump_image)
set(prj_src src/ffplay/ffplay_org.c
            src/ffplay/cmdutils.c
    )

set(prj_inc_dir PUBLIC src/ffplay/
                PUBLIC ${ffmpeg_dir}
                )

add_executable(${prj_name} ${prj_src})
target_link_libraries(${prj_name} ${ffmpeg_lib} m SDL2main SDL2)
target_link_directories(${prj_name} ${ffmpeg_lib_dir})
target_include_directories(${prj_name} ${prj_inc_dir})
target_include_directories(${prj_name} ${bmp_dir})

# ------------------- dump image -------------------
set(prj_name dump_image)
set(prj_src src/ffplay/dump_image.c
            src/ffplay/cmdutils.c
            src/rgb2bmp/frame_rgb.c 
            src/rgb2bmp/rgb2bmp.c
    )

set(prj_inc_dir PUBLIC src/ffplay/
                PUBLIC ${ffmpeg_dir}
                )

add_executable(${prj_name} ${prj_src})
target_link_libraries(${prj_name} ${ffmpeg_lib} m SDL2main SDL2)
target_link_directories(${prj_name} ${ffmpeg_lib_dir})
target_include_directories(${prj_name} ${prj_inc_dir})
target_include_directories(${prj_name} ${bmp_dir})

